﻿using System;
using Autodesk.Revit.DB;
using FlexCell;
using YArchitech.Controls;
using YJKMaterialStatistic;

namespace YJKWndrStatisticsExcel.AreaTable.DataManager
{
	public class TechnoEconomicIndicatorInfo
	{
        public TechnoEconomicIndicatorInfo(Autodesk.Revit.DB.Document doc, ref FlexCell.Grid grid, GridSetCommonInfo gridSetInfo)
		{
			this.m_doc = doc;
			this.m_grid = grid;
			this.m_gridSetInfo = gridSetInfo;
		}

		public bool GetStatisticGrid()
		{
			this.StatisticData();
			this.m_grid.Locked = false;
			return this.SetDataToGrid();
		}

		private void StatisticData()
		{
		}

		private bool SetDataToGrid()
		{
			if (this.m_grid == null)
			{
				YJKMessageBox.Show("没有统计数据");
				return false;
			}
			this.m_grid.Cell(1, 1).Text = this.m_gridSetInfo.GridName;
			this.m_grid.Cell(1, 1).FontSize = this.m_gridSetInfo.TitleFontSize;
			this.m_grid.Range(1, 1, this.m_grid.Rows - 1, this.m_grid.Cols - 1).WrapText = true;
			this.m_grid.Range(2, 1, this.m_grid.Rows - 1, this.m_grid.Cols - 1).FontName = this.m_gridSetInfo.FontName;
			this.m_grid.Range(2, 1, this.m_grid.Rows - 1, this.m_grid.Cols - 1).FontSize = this.m_gridSetInfo.FontSize;
			for (int i = 1; i < this.m_grid.Rows; i++)
			{
				this.m_grid.Row(i).AutoFit();
			}
			if (!this.m_gridSetInfo.SetColWidth)
			{
				for (int j = 0; j < this.m_grid.Cols; j++)
				{
					this.m_grid.Column(j).AutoFit();
				}
			}
			this.m_grid.Range(1, 1, this.m_grid.Rows - 1, this.m_grid.Cols - 1).set_Borders(EdgeEnum.Outside, LineStyleEnum.Thick);
			this.m_grid.Range(1, 1, this.m_grid.Rows - 1, this.m_grid.Cols - 1).set_Borders(EdgeEnum.Inside, LineStyleEnum.Thin);
			return true;
		}

        private FlexCell.Grid m_grid;

		private Document m_doc;

		private GridSetCommonInfo m_gridSetInfo;
	}
}
